﻿#ifndef CLOSESHAPE_H
#define CLOSESHAPE_H
#include "IShape.h"
#include <QPointF>
#include <QSizeF>
#include <QRectF>
#include <QColor>
#include <QPainter>
#include <QPainterPath>
#include <memory>
#include <Qt>
#include<QDomElement>

class CloseShape : public IShape{
public:
    explicit CloseShape(const QPointF& pos = { 0, 0 });
    explicit CloseShape(const CloseShape& other);
    virtual ~CloseShape() = default;

    virtual std::shared_ptr<IShape> clone() const = 0;
    virtual std::unique_ptr<IShape> init(const QPointF& pos = { 0, 0 }) = 0;

    //保存svg
    QString toSVG() const override = 0;
    QString svgAttributes() const override;
    bool parseSVGAttributes(const QDomElement& element) override;


    QPainterPath shape() const override = 0;
    QRectF bounds() const override;

    void paint(QPainter& painter) const override;// 绘制函数
    void drawSelection(QPainter& painter) const override;
    void drawlinkPoint(QPainter& painter) const;
    void moveBy(const QPointF& offset) override;
    // 获取连接点（用于后续连线)
    std::vector<QPointF> controlPoints() const override;
    std::vector<QPointF> linkPoints() const override = 0;
    //类型
    Type type() const { return Type::ClosedShape; }
    
   
    // 尺寸与填充颜色
    void setSize(const QSizeF& size);
    void setFillColor(const QColor& color);
    QSizeF Size() const;
    QColor fillColor() const;

    //文本
    void setText(const QString& text);
    QString Text() const;
    void setTextColor(const QColor& color);
    QColor TextColor() const;
    void setFont(const QFont& font);
    QFont Font() const;
   /* void setFontSize(float size);
    float FontSize() const;*/
    void setTextAlignment(Qt::Alignment alignment);
    Qt::Alignment TextAlignment() const;

protected:
    QSizeF m_size;
    QColor m_fillColor;
    // 新增文本属性
    QString m_text;          // 文本内容
    QColor m_textColor;           // 文本颜色
    QFont m_font;
    Qt::Alignment m_textAlignment;  // 文本对齐方式
};

#endif // CLOSESHAPE_H